/* GUI CONVERTED from sosoisc2.p (converter v1.76) Sun May 25 18:34:50 2003 */
/* sosoisc2.p - SALES ORDER SHIPMENT TRAILER                                  */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.12.2.9 $                                                      */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.4            CREATED: 09/21/93   BY: bcm *H127*                */
/* REVISION: 7.4            CREATED: 09/10/94   BY: dpm *FQ97*                */
/* REVISION: 7.4      LAST MODIFIED: 03/31/95   BY: jxz *G0K1*                */
/* REVISION: 7.4      LAST MODIFIED: 06/06/95   BY: jym *G0ND*                */
/* REVISION: 8.5      LAST MODIFIED: 10/05/95   BY: taf *J053*                */
/* REVISION: 7.4      LAST MODIFIED: 12/27/95   BY: ais *G1HG*                */
/* REVISION: 8.5      LAST MODIFIED: 09/26/97   BY: *J21S* Niranjan Ranka     */
/* REVISION: 8.5      LAST MODIFIED: 12/30/97   BY: *J281* Manish K.          */
/* REVISION: 8.6      LAST MODIFIED: 11/07/97   BY: *K15N* Jim Williams       */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 07/13/98   BY: *J2MD* A. Philips         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 07/06/00   BY: *L116* Rajesh Kini        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* myb                */
/* REVISION: 9.1      LAST MODIFIED: 01/24/01   BY: *M10S* Rajaneesh S.       */
/* REVISION: 9.1      LAST MODIFIED: 10/13/00   BY: *N0WB* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Old ECO marker removed, but no ECO header exists *F247*                    */
/* Old ECO marker removed, but no ECO header exists *F379*                    */
/* Revision: 1.12.2.7       BY: Katie Hilbert  DATE: 04/01/01 ECO: *P002*     */
/* Revision: 1.12.2.8       BY: Vandna Rohira  DATE: 04/28/03 ECO: *N1YL*     */
/* $Revision: 1.12.2.9 $    BY: Narathip W.    DATE: 05/21/03 ECO: *P0S8*     */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdeclre.i}
{cxcustom.i "SOSOISC2.P"}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define shared variable so_mstr_recid as recid.
define shared variable undo-all like mfc_logical no-undo.
define shared variable eff_date like glt_effdate.
define shared variable undo_isc1 like mfc_logical.
define shared variable so_db   like dc_name.
define shared variable ship_db like dc_name.
define new shared variable so_recno as recid.

define buffer somstr for so_mstr.
define buffer simstr for si_mstr.
define shared frame f.
define shared frame sotot.

define variable sonbr     like so_nbr no-undo.
define variable ship_via  like so_shipvia no-undo.
define variable ship_date like so_ship_date no-undo.
define variable bol       like so_bol no-undo.
define variable rmks      like so_rmks no-undo.
define variable inv_nbr   like so_inv_nbr no-undo.
define variable to_inv    like so_to_inv no-undo.
define variable invoiced  like so_invoiced no-undo.
define variable err_flag  as integer no-undo.
define variable w-accept  like mfc_logical no-undo.
define variable l_consolidate_ok as logical   no-undo.
define variable l_msg_text       as character no-undo.
{&SOSOISC2-P-TAG5}
define variable l_inv_nbr        like so_inv_nbr no-undo.

{sosois1.i}
{mfsotrla.i}

for first txc_ctrl
   fields (txc__qad03)
   no-lock:
end. /* FOR FIRST txc_ctrl */

{&SOSOISC2-P-TAG6}
assign
   maint = yes
   undo-all = yes.

find so_mstr where recid(so_mstr) = so_mstr_recid
   exclusive-lock.

so_recno = recid(so_mstr).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
so_shipvia     colon 15
   so_inv_nbr     colon 55 skip
   so_ship_date   colon 15
   so_to_inv      colon 55 skip
   so_bol         colon 15
   so_invoiced    colon 55
   so_rmks        colon 15
 SKIP(.4)  /*GUI*/
with frame f side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-f-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame f = F-f-title.
 RECT-FRAME-LABEL:HIDDEN in frame f = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame f =
  FRAME f:HEIGHT-PIXELS - RECT-FRAME:Y in frame f - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME f = FRAME f:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame f:handle).

assign
   sonbr = ""
   ship_via = ""
   ship_date = ?
   bol = ""
   rmks = ""
   inv_nbr = ""
   to_inv = no
   invoiced = no
   l_inv_nbr = so_mstr.so_inv_nbr.
{&SOSOISC2-P-TAG1}
settrl:
do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

/*
   if txc__qad03
   then
      display
         l_nontaxable_lbl
         nontaxable_amt
         l_taxable_lbl
         taxable_amt
         with frame sotot.
   else
      display
         "" @ l_nontaxable_lbl
         "" @ nontaxable_amt
         "" @ l_taxable_lbl
         "" @ taxable_amt
         with frame sotot.
*/

/*
   display
      so_curr
      line_total
      so_disc_pct
      disc_amt
      tax_date
      user_desc[1]  so_trl1_cd  so_trl1_amt
      user_desc[2]  so_trl2_cd  so_trl2_amt
      user_desc[3]  so_trl3_cd  so_trl3_amt
      tax_amt
      ord_amt
      tax_edit
   with frame sotot.
   {&SOSOISC2-P-TAG2}
   {&SOSOISC2-P-TAG7}
   set so_shipvia so_ship_date so_bol so_rmks
      so_inv_nbr so_to_inv so_invoiced
   with frame f.
   {&SOSOISC2-P-TAG8}
   {&SOSOISC2-P-TAG3}
*/

   w-accept = no.
   if can-find(mfc_ctrl where mfc_module = "SO" and
      mfc_seq = 170) then do while not w-accept:
      {mfmsg01.i 32 1 w-accept}   /* please accept */
      if w-accept then leave.
      {&SOSOISC2-P-TAG9}
/*      
      set so_shipvia so_ship_date so_bol so_rmks
         so_inv_nbr so_to_inv so_invoiced
      with frame f.
*/      
      {&SOSOISC2-P-TAG10}
   end. /* multiple bol set */

   if so_inv_nbr <> "" then do for somstr:
         /* CHECK FOR DUPLICATE INVOICE NUMBERS */

         for first somstr
               fields(so_bol so_curr so_disc_pct so_invoiced so_inv_nbr
                      so_nbr so_pst_pct so_rmks so_shipvia so_ship_date
                      so_site so_tax_pct so_to_inv so_trl1_amt so_trl1_cd
                      so_trl2_amt so_trl2_cd so_trl3_amt so_trl3_cd)
               where somstr.so_inv_nbr = so_mstr.so_inv_nbr
               and somstr.so_nbr <> so_mstr.so_nbr
               no-lock:
         end. /* FOR FIRST SOMSTR */

         for first ar_mstr
               fields(ar_nbr)
               where ar_mstr.ar_nbr = so_mstr.so_inv_nbr no-lock:
         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST AR_MSTR */

         for first ih_hist
               fields(ih_inv_nbr ih_nbr)
               where ih_inv_nbr = so_mstr.so_inv_nbr
               and ih_nbr = so_mstr.so_nbr no-lock:
         end. /* FOR FIRST IH_HIST */

         if available somstr
         then do:

            for first si_mstr
                  fields(si_site)
                  where si_mstr.si_site = so_mstr.so_site no-lock:
            end. /* FOR FIRST SI_MSTR */

            for first simstr
                  fields(si_site)
                  where simstr.si_site = somstr.so_site no-lock:
            end. /* FOR FIRST SIMSTR */

         end.

         if (available ar_mstr)
         then do:
            /*next-prompt so_mstr.so_inv_nbr with frame d.*/
            /* DUPLICATE INVOICE NUMBER */
            {pxmsg.i &MSGNUM=1165 &ERRORLEVEL=3}
            undo settrl, retry.
         end.
         else
         if (available ih_hist)
         then do:
            /*next-prompt so_mstr.so_inv_nbr with frame d.*/
            /* History for Sales Order/Invoice exists */
            {pxmsg.i &MSGNUM=1045 &ERRORLEVEL=3}
            undo settrl, retry.
         end.
         else do:
            if available somstr then do:

               /* PROCEDURE FOR CONSOLIDATION RULES */
               {gprun.i ""soconso.p"" "(input 1,
                     input somstr.so_nbr,
                     input so_mstr.so_nbr,
                     output l_consolidate_ok,
                     output l_msg_text)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               if not l_consolidate_ok then do:
                  /*next-prompt so_mstr.so_inv_nbr with frame d.*/
                  /* Mismatch with open invoice - can't consolidate */
                  {pxmsg.i &MSGNUM=1046 &ERRORLEVEL=3}
                  undo settrl, retry.
               end.
               else do:
                  /* Invoice already open.  Consolidation will be done */
                  {pxmsg.i &MSGNUM=1047 &ERRORLEVEL=2}
                  hide message.
               end.
            end.   /* avail somstr */
         end.  /* no ih_hist */
         {&SOSOISC2-P-TAG4}
      end.

      if so_mstr.so_inv_nbr = "" and so_mstr.so_invoiced = yes then do:
         /*next-prompt so_mstr.so_inv_nbr with frame f.*/
         {pxmsg.i &MSGNUM=40 &ERRORLEVEL=3} /* Blank not allowed */
         undo settrl, retry.
      end.

      /* DELETE TYPE 16 TRANSACTION IF INVOICE NUMBER IS CHANGED */
      if so_mstr.so_inv_nbr <> l_inv_nbr
      then do:
         {gprun.i ""txdelete.p"" "(input "16",
                                   input l_inv_nbr,
                                   input so_mstr.so_nbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.

          end. /* IF so_mstr.so_inv_nbr <> l_inv_nbr .......... */

          /* COPY THESE VALUE INTO REMOTE DATABASE IF NECESSARY */
          if ship_db <> so_db then do:
             {gprun.i ""gpalias3.p"" "(ship_db, output err_flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.

             if err_flag = 2 or err_flag = 3 then do:
                {mfmsg03.i 2510 4 "ship_db" """" """"}
                /* DB NOT CONNECTED*/
         pause.
         undo settrl, retry.
      end.
   end.

   assign
      sonbr = so_nbr
      ship_via = so_shipvia
      ship_date = so_ship_date
      bol = so_bol
      rmks = so_rmks
      inv_nbr = so_inv_nbr
      to_inv = so_to_inv
      invoiced = so_invoiced.

   /* UPDATING SO TRAILER INFO AT REMOTE SITE */
   {gprun.i ""sosoisc3.p"" "(input sonbr,
                    input ship_via,
                    input ship_date,
                    input bol,
                    input rmks,
                    input inv_nbr,
                    input to_inv,
                    input invoiced)"
      }
/*GUI*/ if global-beam-me-up then undo, leave.


   if ship_db <> so_db then do:
      {gprun.i ""gpalias3.p"" "(so_db, output err_flag)" }
/*GUI*/ if global-beam-me-up then undo, leave.

      if err_flag = 2 or err_flag = 3 then do:
         {mfmsg03.i 2510 4 "so_db" """" """"}
         /* DB NOT CONNECTED*/
         pause.
         undo settrl, retry.
      end.
   end.

   /* SET PICK LIST REQUIRED TO YES */
   assign
      undo-all = no
      undo_isc1 = false.
end.
